]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
Track changes to WM_CLASS
authorColin Walters <walters@verbum.org>
Tue, 24 May 2011 23:42:07 +0000 (19:42 -0400)
committerColin Walters <walters@verbum.org>
Wed, 25 May 2011 16:09:52 +0000 (12:09 -0400)
LibreOffice changes applications dynamically; we should support this.

https://bugzilla.gnome.org/show_bug.cgi?id=649315

src/shell-window-tracker.c

index 1c7cf51447466f2967ceb0ea1c892667d70a1e4c..ef555261f763402b65f2c94eb767a313ba3ed9bf 100644 (file)
@@ -508,6 +508,33 @@ on_transient_window_title_changed (MetaWindow      *window,
   track_window (self, window);
 }
 
+static void
+update_focus_app (ShellWindowTracker *self)
+{
+  MetaWindow *new_focus_win;
+  ShellApp *new_focus_app;
+
+  new_focus_win = meta_display_get_focus_window (meta_screen_get_display (shell_global_get_screen (shell_global_get ())));
+  new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (self, new_focus_win) : NULL;
+
+  set_focus_app (self, new_focus_app);
+}
+
+static void
+on_wm_class_changed (MetaWindow  *window,
+                     GParamSpec  *pspec,
+                     gpointer     user_data)
+{
+  ShellWindowTracker *self = SHELL_WINDOW_TRACKER (user_data);
+
+  /* It's simplest to just treat this as a remove + add. */
+  disassociate_window (self, window);
+  track_window (self, window);
+  /* also just recaulcuate the focused app, in case it was the focused
+     window that changed */
+  update_focus_app (self);
+}
+
 static void
 track_window (ShellWindowTracker *self,
               MetaWindow      *window)
@@ -534,6 +561,8 @@ track_window (ShellWindowTracker *self,
       g_signal_connect (window, "notify::title", G_CALLBACK (on_transient_window_title_changed), self);
     }
 
+  g_signal_connect (window, "notify::wm-class", G_CALLBACK (on_wm_class_changed), self);
+
   _shell_app_add_window (app, window);
 
   g_signal_emit (self, signals[TRACKED_WINDOWS_CHANGED], 0);
@@ -884,13 +913,7 @@ on_focus_window_changed (MetaDisplay        *display,
                          GParamSpec         *spec,
                          ShellWindowTracker *tracker)
 {
-  MetaWindow *new_focus_win;
-  ShellApp *new_focus_app;
-
-  new_focus_win = meta_display_get_focus_window (display);
-  new_focus_app = new_focus_win ? shell_window_tracker_get_window_app (tracker, new_focus_win) : NULL;
-
-  set_focus_app (tracker, new_focus_app);
+  update_focus_app (tracker);
 }
 
 /**